import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/index.vue'
import Main from '../views/index/main.vue'

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)

  const routes = [
  {
    path: '/',
    redirect: '/home/main'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    children: [
      {
        path: 'main',
        component: Main,
      },{
        path: 'catagory',
        component: ()=>import('@/views/index/catagory.vue')
      }
    ]
  },
  {
    path: '/control',
    component: ()=> import('@/views/controlPage.vue')
  },
  {
    path: '/commit',
    componet: ()=> import('@/views/commitPage.vue')
  },
  
  {
    path: '/search',
    component: ()=>import('@/views/search/index.vue'),
    children: [
      {
        path: 'main',
        component: () => import('@/views/search/searchPage.vue')
      },
      {
        path: 'list',
        component: () => import('@/views/search/listPage.vue')
      }
    ]
  },
  {
    path: '/songs',
    component: ()=>import('@/views/songsPage.vue')
  },
  {
    path: '/singer',
    component: ()=> import('@/views/singer/index.vue'),
    children: [
      {
        path: 'list',
        component: ()=> import('@/views/singer/listPage.vue'),
      },
      {
        path: 'detail',
        component: ()=> import('@/views/singer/detailPage.vue'),
      }
    ]
  },

  {
    path: '/video',
    component: ()=> import('@/views/video/videoPage.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
